package com.atguigu.yygh.sms.receiver;

import com.atguigu.yygh.rabbit.config.MQConst;
import com.atguigu.yygh.sms.service.SmsService;
import com.atguigu.yygh.vo.sms.SmsVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA
 *
 * @Date: 2023/1/8 - 11:53
 * @Author: Hyoung
 * @Description:
 */
@Component
@Slf4j
public class SmsReceiver {

    @Autowired
    private SmsService smsService;

    @RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue(
                            value = MQConst.QUEUE_SMS, durable = "true"),
                    exchange = @Exchange(value = MQConst.EXCHANGE_DIRECT_SMS),
                    key = {MQConst.ROUTING_SMS}))
    public void send(SmsVo smsVo) {
        log.info("SmsReceiver 监听器监听到了消息.....");
        smsService.send(smsVo);
    }
}
